home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / TextHarvest / TextHarvest-Install.exe / {app} / ScrOutCSVDemo.txt < prev    next >
Text File  |  2005-02-01  |  9KB  |  293 lines

  1. ;===============================================================================
  2. ;
  3. ;   This is the actual script used by Pinnacle Software to validate the
  4. ;   OutCSV command. You can view it whenever you need some examples of
  5. ;   OutCSV usage.
  6. ;
  7. ;   To try out this script, use any text input file -- it only reads the
  8. ;   first line. The output (when everything is working fine) is simply
  9. ;   a tidy series of sample output styles.
  10. ;
  11. ;===============================================================================
  12. ; Configuration section
  13. ;===============================================================================
  14.  
  15. Config
  16.   $CfgEnableOptionX = 'N'
  17.   $CfgEnableOptionY = 'N'
  18.   $CfgEnableOptionZ = 'N'
  19.   $CfgCopyright     = 'Copyright ⌐ 2004, 2005 by Pinnacle Software'
  20.   $CfgVersion       = '2.00.00'
  21.   $CfgProgrammer    = 'Timothy Campbell'
  22.   $CfgEmail         = 'info@parse-o-matic.com'
  23.   $CfgLicense       = 'This script may be used, at no charge, with any ' >>
  24.     'script-enabled Parse-O-Matic application, subject to any additional ' >>
  25.     'licensing requirements of such application.'
  26. End
  27.  
  28. ;===============================================================================
  29. ; FileInit
  30. ;===============================================================================
  31.  
  32. FileInit
  33.   Error = '^^^^^^^^^   ERROR '
  34.   Error = Padded Error 80 'Right' '^'
  35.   Sep1 = Padded '' 80 'Left' '='
  36.   OutEnd Sep1
  37.   Label = 'OutCSV Exercise Script'
  38.   Label = Padded Label 80 'Center' ' '
  39.   OutEnd Label
  40.   OutEnd Sep1
  41. End
  42.  
  43. ;-------------------------------------------------------------------------------
  44. ; Standard OutCSV usage (quoted)
  45. ;-------------------------------------------------------------------------------
  46.  
  47. Output '[SAMPLE 01] '
  48.  
  49. OutCSV '' 'Init'
  50. OutCSV 'One'
  51. OutCSV 'Two'
  52. OutCSV 'Three'
  53. OutCSV '' 'Done'
  54.  
  55. If $OutCSVRec <> '"One","Two","Three"' OutEnd Error
  56.  
  57. ;-------------------------------------------------------------------------------
  58. ; Standard OutCSV usage (unquoted)
  59. ;-------------------------------------------------------------------------------
  60.  
  61. Output '[SAMPLE 02] '
  62.  
  63. OutCSV '' 'Init'
  64. OutCSV 'One' 'Unquoted'
  65. OutCSV 'Two' 'Unquoted'
  66. OutCSV 'Three' 'Unquoted'
  67. OutCSV '' 'Done'
  68.  
  69. If $OutCSVRec <> 'One,Two,Three' OutEnd Error
  70.  
  71. ;-------------------------------------------------------------------------------
  72. ; Standard OutCSV usage (nulls, quoted, unquoted)
  73. ;-------------------------------------------------------------------------------
  74.  
  75. Output '[SAMPLE 03] '
  76.  
  77. OutCSV '' 'Init'
  78. OutCSV 3 'Null'
  79. OutCSV 5.5 'Unquoted'
  80. OutCSV 'Quoted'
  81. MyVar = 1
  82. OutCSV MyVar 'Null'
  83. OutCSV '' 'Null'  ; This will be ignored
  84. OutCSV 'Quoted' 'Quoted'
  85. OutCSV '1' 'Null'
  86. OutCSV '' 'Done'
  87.  
  88. If $OutCSVRec <> ',,,5.5,"Quoted",,"Quoted",' OutEnd Error
  89.  
  90. ;-------------------------------------------------------------------------------
  91. ; MinWidth
  92. ;-------------------------------------------------------------------------------
  93.  
  94. Output '[SAMPLE 04] '
  95.  
  96. OutCSV 'MinWidth 5' 'Control'
  97. OutCSV '' 'Init'
  98. OutCSV '3' 'Null'
  99. OutCSV 5.5 'Unquoted'
  100. OutCSV 'Quoted'
  101. OutCSV '1' 'Null'
  102. OutCSV 'Quoted' 'Quoted'
  103. OutCSV '1' 'Null'
  104. OutCSV '' 'Done'
  105.  
  106. If $OutCSVRec <> '     ,     ,     ,  5.5,"Quoted",     ,"Quoted",     ' >>
  107.   OutEnd Error
  108.  
  109. ;-------------------------------------------------------------------------------
  110. ; MinWidth and MaxWidth
  111. ;-------------------------------------------------------------------------------
  112.  
  113. Output '[SAMPLE 05] '
  114.  
  115. OutCSV 'MinWidth 5' 'Control'
  116. OutCSV 'MaxWidth 6' 'Control'
  117. OutCSV '' 'Init'
  118. OutCSV '3' 'Null'
  119. OutCSV 5.5 'Unquoted'
  120. OutCSV 'Quoted'
  121. OutCSV '1' 'Null'
  122. OutCSV 'Quoted' 'Quoted'
  123. OutCSV '1' 'Null'
  124. OutCSV '' 'Done'
  125.  
  126. If $OutCSVRec <> '     ,     ,     ,  5.5,"Quot",     ,"Quot",     ' >>
  127.   OutEnd Error
  128.  
  129. ;-------------------------------------------------------------------------------
  130. ; Changing MinWidth and MaxWidth after the Init
  131. ;-------------------------------------------------------------------------------
  132.  
  133. Output '[SAMPLE 06] '
  134.  
  135. OutCSV 'MinWidth 5' 'Control'
  136. OutCSV 'MaxWidth 5' 'Control'
  137. OutCSV '' 'Init'
  138. OutCSV '3' 'Null'
  139. OutCSV 5.5 'Unquoted'
  140. OutCSV 'Quoted'
  141. OutCSV '1' 'Null'
  142. OutCSV 'MinWidth 5' 'Control'
  143. OutCSV 'MaxWidth 8' 'Control'
  144. OutCSV 'Quoted' 'Quoted'
  145. OutCSV '1' 'Null'
  146. OutCSV '' 'Done'
  147.  
  148. If $OutCSVRec <> '     ,     ,     ,  5.5,"Quo",     ,"Quoted",     ' >>
  149.   OutEnd Error
  150.  
  151. ;-------------------------------------------------------------------------------
  152. ; Alternative separator string (space, vertical bar, space)
  153. ;-------------------------------------------------------------------------------
  154.  
  155. Output '[SAMPLE 07] '
  156.  
  157. OutCSV 'MinWidth 5' 'Control'
  158. OutCSV 'MaxWidth 5' 'Control'
  159. OutCSV ' | ' 'Init'  ; Alternative separator string for this section only
  160. OutCSV '3' 'Null'
  161. OutCSV 5.5 'Unquoted'
  162. OutCSV 'Quoted'
  163. OutCSV '1' 'Nulls'
  164. OutCSV 'MinWidth 8' 'Control'
  165. OutCSV 'MaxWidth 8' 'Control'
  166. OutCSV 'Quoted' 'Quoted'
  167. OutCSV '1' 'Null'
  168. OutCSV '' 'Done'
  169.  
  170. If $OutCSVRec <> >>
  171.   '      |       |       |   5.5 | "Quo" |       | "Quoted" |         ' >>
  172.   OutEnd Error
  173.  
  174. ;-------------------------------------------------------------------------------
  175. ; QuoteChar None
  176. ;-------------------------------------------------------------------------------
  177.  
  178. Output '[SAMPLE 08] '
  179.  
  180. OutCSV 'MinWidth 3'     'Control'
  181. OutCSV 'MaxWidth 3'     'Control'
  182. OutCSV 'QuoteChar None' 'Control'  ; QuoteChar set to None (i.e. nothing)
  183. OutCSV '||' 'Init'
  184. OutCSV 1 'Null'
  185. OutCSV 'BB' 'Unquoted'
  186. OutCSV 'CC' 'Quoted'
  187. OutCSV 'DD' 'Unquoted'
  188. OutCSV 'EE' 'Unquoted'
  189. OutCSV '' 'Done'
  190.  
  191. If $OutCSVRec <> '   || BB||CC || DD|| EE' OutEnd Error
  192.  
  193. ;-------------------------------------------------------------------------------
  194. ; Separator None
  195. ;-------------------------------------------------------------------------------
  196.  
  197. Output '[SAMPLE 09] '
  198.  
  199. OutCSV 'MinWidth 3'     'Control'
  200. OutCSV 'MaxWidth 3'     'Control'
  201. OutCSV 'QuoteChar None' 'Control'  ; QuoteChar set to None (i.e. nothing)
  202. OutCSV 'None' 'Init'               ; Set separator to 'None' ('Null' also works)
  203. OutCSV '1' 'Null'
  204. OutCSV 'BB' 'Unquoted'
  205. OutCSV 'CC' 'Quoted'
  206. OutCSV 'DD' 'Unquoted'
  207. OutCSV 'EE' 'Unquoted'
  208. OutCSV '' 'Done'
  209.  
  210. If $OutCSVRec <> '    BBCC  DD EE' OutEnd Error
  211.  
  212. ;-------------------------------------------------------------------------------
  213. ; Resetting Controls settings back to normal and turn fields on and off
  214. ;-------------------------------------------------------------------------------
  215.  
  216. Output '[SAMPLE 10] '
  217.  
  218. OutCSV 'MinWidth 0'  'Control'  ; Reset MinWidth
  219. OutCSV 'MaxWidth 0'  'Control'  ; Reset MaxWidth
  220. OutCSV 'QuoteChar "' 'Control'  ; Reset QuoteChar to standard
  221. OutCSV '' 'Init'                ; Separator back to standard (i.e. comma)
  222. OutCSV 'This'
  223. OutCSV 'and'
  224. OutCSV 'ERROR-A' '-Unquoted'
  225. OutCSV 'that' '+'
  226. OutCSV 'ERROR-B' '-'
  227. OutCSV 'ERROR-C' '-'
  228. OutCSV 'etcetera' '+Quoted'
  229. OutCSV '' 'Done'
  230.  
  231. If $OutCSVRec <> '"This","and","that","etcetera"' OutEnd Error
  232.  
  233. ;-------------------------------------------------------------------------------
  234. ; Quote-State Redefinition
  235. ;-------------------------------------------------------------------------------
  236.  
  237. Output '[SAMPLE 11] '
  238.  
  239. OutCSV '' 'Init'
  240. OutCSV 1
  241. OutCSV 2 'Unquoted...'   ; Redefining the default quoting state
  242. OutCSV 3
  243. OutCSV 'ERROR-A' '-'     ; Turning fields off
  244. OutCSV 'ERROR-B'
  245. OutCSV 'A' '+Quoted...'  ; Fields back on, and restoring the usual quote-state
  246. OutCSV 'B'
  247. OutCSV '' 'Done'
  248.  
  249. If $OutCSVRec <> '"1",2,3,"A","B"' OutEnd Error
  250.  
  251. ;-------------------------------------------------------------------------------
  252. ; Stop
  253. ;-------------------------------------------------------------------------------
  254.  
  255. Output '[SAMPLE 12] '
  256.  
  257. OutCSV 'QuoteChar None' 'Control'
  258. OutCSV ' ' 'Init'
  259. OutCSV 1
  260. OutCSV 2
  261. OutCSV 3
  262. OutCSV 'A'
  263. OutCSV 'B'
  264. OutCSV '' 'Stop'
  265. OutEnd $OutCSVRec
  266.  
  267. If $OutCSVRec <> '1 2 3 A B' OutEnd Error
  268.  
  269. ;-------------------------------------------------------------------------------
  270. ; SetWidth, Separator and concatenation of additional values
  271. ;-------------------------------------------------------------------------------
  272.  
  273. Output '[SAMPLE 13] '
  274.  
  275. OutCSV 'QuoteChar Null'  'Control'  ; Same as QuoteChar None
  276. OutCSV 'Separator  | '   'Control'  ; New default separator: space-line-space
  277. OutCSV 'SetWidth 5'      'Control'  ; Set both MinWidth and MaxWidth
  278. OutCSV '' 'Init'
  279. OutCSV 1
  280. OutCSV 'QuoteChar "'     'Control'
  281. OutCSV 2
  282. OutCSV 'QuoteChar None'  'Control'
  283. OutCSV 1 'Unquoted' 2 3             ; Concatenation of additional values
  284. OutCSV 'A' '' 'B' 'C'               ; As above; note second parm placeholder
  285. OutCSV '' 'Done'
  286.  
  287. If $OutCSVRec <> '1     | "2  " |   123 | ABC  ' OutEnd Error
  288.  
  289. ;-------------------------------------------------------------------------------
  290. ; We only process one input line, so we're done
  291. ;-------------------------------------------------------------------------------
  292. Stop
  293.